﻿Chenxin.UI.ShowListBillPg = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/ShowListBill.ashx',
    createGrid: function() {
		_this = this;
        return new Chenxin.UI.ReportGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            height: 400,
            hasTotal:false,
            renderTo: 'divShowBillList',
            hasCheckBox: false,
            autoLoad: false,
            modelId: 'BillId',
            id: 'BillList',
            title: '开单明细',
            pageSize: 100,
            scope: this,
            hasPage: true,
			sortStyle:'server',
            cellBorder: true,
            onClick: function(id) {
                var str = id;
            },
			createTitleTool:function(){					
				return [{
					text: '<span id="" class="x-grid-export" style="width:90px" title="导出全部数据">导出全部数据</span>',
					scope:this,
					title:'导出全部数据',
					handler:function(el){
						_this.exportAll();
					}
				}];
			},
            columns: {
                IsFinish: {
                    width: 30,
                    head: "封",
                    renderer: function(val, field, row) {
                        if (val == true) {
                            return '<input type="checkbox" disabled="disabled" checked="checked"/>';
                        }
                        return '<input type="checkbox" disabled="disabled"/>'
                    },
                    sortable: true,
                    inTotal: false
                },
                IsRecheck: {
                    width: 30,
                    head: "核",
                    renderer: function(val, field, row) {
                        if (val == true) {
                            return '<input type="checkbox" disabled="disabled" checked="checked"/>';
                        }
                        return '<input type="checkbox" disabled="disabled"/>'
                    },
                    sortable: true,
                    inTotal: false
                },
                AreaName: {
                    width: 80,
                    head: "商圈",
                    style: 'text-align:left',
                    sortable: true,
                    captionCol: true

                },
                BillDepartName: {
                    width: 80,
                    head: "门店",
                    style: 'text-align:left',
                    sortable: true,
                    inTotal: false
                },
                Status: {
                    width: 40,
                    head: "状态",
                    sortable: true,
                    inTotal: false
                },
                ContractCode: {
                    width: 130,
                    head: "成交编号",
                    sortable: true,
                    style: 'text-align:left',
					sortField:'t_Contract_Finance_BillInfo.ContractCode',
                    inTotal: false
                },
                ContractCompany: {
                    width: 130,
                    head: "合同所属",
                    sortable: true,
                    style: 'text-align:left',
                    inTotal: false
                },
                HouseAddress: {
                    width: 272,
                    head: "房屋地址",
                    style: 'text-align:left',
                    inTotal: false
                },
                CustomerName: {
                    width: 100,
                    head: "客户姓名",
                    style: 'text-align:left',
                    inTotal: false
                },
                FundName: {
                    width: 100,
                    head: "款项名称",
                    sortable: true,
                    style: 'text-align:left',
                    inTotal: false
                },
                BillCode: {
                    width: 120,
                    head: "开单号",
                    sortable: true,
                    style: 'text-align:left',
                    inTotal: false
                },
                BillDate: {
                    width: 70,
                    head: "开单日期",
                    sortable: true,
                    inTotal: false
                },
                TBillMoney: {
                    width: 110,
                    head: "开单金额",
                    sortable: true,
                    sortField: 'BillMoney',
                    style: 'text-align:right',
                    inTotal: true
                },
                RecMoney: {
                    width: 100,
                    head: "收款",
                    style: 'text-align:right',
                    inTotal: true
                },
                Payment: {
                    width: 100,
                    head: "付款",
                    style: 'text-align:right',
                    inTotal: true
                },
                PayDate: {
                    width: 70,
                    head: "收付款日期",
                    sortable: true,
                    inTotal: false
                },
                PayOprEmpName: {
                    width: 60,
                    head: "收款人",
                    sortable: true,
                    inTotal: false
                },
                InvoiceCode: {
                    width: 60,
                    head: "发票单号",
                    sortable: true,
                    inTotal: false
                },
                InvoiceDate: {
                    width: 80,
                    head: "发票日期",
                    sortable: true,
                    inTotal: false,
                    sortField: 't_Contract_Finance_BillInfo.InvoiceDate',
                },
                BusinessType: {
                    width: 60,
                    head: "成交类型",
                    sortable: true,
                    inTotal: false
                },
                AchievementDate: {
                    width: 80,
                    head: "归属日期",
                    sortable: true,
                    inTotal: false,
                    renderer: function(val, field, row) {
                        if (val.indexOf('.') >= 0) {
                            return val.substring(0, 4) + '年' + val.substring(5.1) + '月';
                        }
                        else {
                            return '';
                        }
                    }
                },
                InvoiceMemo: {
                    width: 200,
                    head: "发票领取记录",
                    style: 'text-align:left',
                    inTotal: false
                },
                BillPlace: {
                    width: 120,
                    head: "开单地点",
                    sortable: true,
                    style: 'text-align:left',
                    inTotal: false
                },
                PayPlace: {
                    width: 120,
                    head: "收付款地点",
                    sortable: true,
                    style: 'text-align:left',
                    inTotal: false
                }
            },
            rowRenderer: function(row, index, dl) {
                if (row.Status == "已收" || row.Status == "已付") {
                    dl.css("background-color", "#FFFFCC");
                } else if (row.Status == "作废") {
                    dl.css("background-color", "gray");
                } else {
                    dl.css("background-color", "#CCFFCC");
                }
            }
        });
    },
	exportAll:function(){
		 _this = this;
        paramStr = this.search.getParamJson();
        paramStr.op = 'exportAll';
        Chenxin.Msg.Waiting.show();
		Chenxin.Fn.exportToExcelByServer(this.actionUrl,paramStr,'导出文件');
		//$.ajax({ url: this.actionUrl, data: paramStr,async:false});
		Chenxin.Msg.Waiting.hide();
	},
    createSearch: function() {
        return new Chenxin.UI.ShowListBillSrh({
            scope: this
        });
    },
    initEvent: function() {
        var objPg = this;
        /***************事件：底部按钮点击事件**********/
        $('.LeftFooter a').click(function() {
            objPg.bindBottomBar(this);
        });
    },
    bindBottomBar: function(obj) {
        switch (obj.name) {
            //开单作废                        
            case "CancelBill":
                this.CancelBill();
                break;
            //收付款登记                        
            case "PaymentReg":
                this.PaymentReg();
                break;
            //复核                        
            case "Check":
                this.CheckBillInfo();
                break;
            //反复核                                
            case "UnCheck":
                this.UnCheckBillInfo();
                break;
            //作废收付款                                
            case "CancelPayment":
                this.CancelPayment();
                break;
            //登记发票                                
            case "RegInvoice":
                this.RegInvoice();
                break;
            //发票领取登记                        
            case "RegInvoiceRev":
                this.RegInvoiceRev();
                break;
            //财务封帐                        
            case "CloseAccount":
                this.CloseAccount();
                break;
            //解除封帐                        
            case "OpenAccount":
                this.OpenAccount();
                break;
            //开单打印    
            case "PrintBill":
                this.PrintBill();
                break;
            //打印发票 
            case "PrintInvoice":
                this.PrintInvoice();
                break;
            default:
                alert("此功能未开通");
                break;
        }
    },
    PrintInvoice: function() {
        var _this = this;
        if (!this.currentId) {
            alert('请先选择一条开单记录！');
            return;
        };
        if (this.grid.getCurrentRecord().Status != "已收") {
            alert("只有“已收”单据可打印发票！");
            return false;
        };
        if (_this.printInvoiceForm == undefined) {
            _this.printInvoiceForm = new Chenxin.UI.PrintInvoiceForm({
                scope: _this,
                op: 'printinvoice'
            });
        };
        if (_this.printInvoiceForm.show('printinvoice') == false) return;
        Chenxin.ajax({
            type: "get",
            dataType: "json",
            url: _this.actionUrl,
            data: { op: 'getprintmodel', billId: this.grid.getCurrentRecord().BillId },
            onSuccess: function(data) {
                _this.printInvoiceForm.reset();                
                _this.printInvoiceForm.fitData(data.model);
            }
        });
    },
    PrintBill: function() {
        var objFrm = this;
        if (!this.currentId) {
            alert('请先选择一条开单记录！');
            return;
        };
        if (this.grid.getCurrentRecord().Status == "作废") {
            alert("此开单已作废，不可打印");
            return false;
        };
        if (this.grid.getCurrentRecord().InOrOut == "1") {//收款单
            if (objFrm.printInForm == undefined) {
                objFrm.printInForm = new Chenxin.UI.PrintInBillForm({
                    scope: objFrm,
                    op: 'reprintview'
                });
            };

            if (objFrm.printInForm.show('reprintview') == false) return;
            Chenxin.ajax({
                type: "get",
                dataType: "json",
                url: objFrm.printInForm.actionUrl,
                data: { op: 'getprintmodel', billId: this.grid.getCurrentRecord().BillId },
                onSuccess: function(data) {
                    objFrm.printInForm.reset();
                    objFrm.printInForm.fitData(data.model);
                }
            });
        } else {//付款单
            if (this.grid.getCurrentRecord().FundName != "代付房款") {
                if (objFrm.printOutForm == undefined) {
                    objFrm.printOutForm = new Chenxin.UI.PrintOutBillForm({
                        scope: objFrm,
                        op: 'reprintview'
                    });
                };

                if (objFrm.printOutForm.show('reprintview') == false) return;
                Chenxin.ajax({
                    type: "get",
                    dataType: "json",
                    url: objFrm.printOutForm.actionUrl,
                    data: { op: 'getprintmodel', billId: this.grid.getCurrentRecord().BillId },
                    onSuccess: function(data) {
                        objFrm.printOutForm.reset();
                        objFrm.printOutForm.fitData(data.model);
                    }
                });
            } else {
                if (objFrm.printHouseForm == undefined) {
                    objFrm.printHouseForm = new Chenxin.UI.PrintHouseBillForm({
                        scope: objFrm,
                        op: 'reprintview'
                    });
                };

                if (objFrm.printHouseForm.show('reprintview') == false) return;
                Chenxin.ajax({
                    type: "get",
                    dataType: "json",
                    url: objFrm.printHouseForm.actionUrl,
                    data: { op: 'getprintmodel', billId: this.grid.getCurrentRecord().BillId },
                    onSuccess: function(data) {
                        objFrm.printHouseForm.reset();
                        objFrm.printHouseForm.fitData(data.model);
                    }
                });
            };
        };
    },
    CancelBill: function() {
        if (!this.currentId) {
            alert('请先选择一条开单记录！');
            return;
        }
        if (this.grid.getCurrentRecord().Status == "作废") {
            alert("此开单已作废，不可作废");
            return false;
        } else if (this.grid.getCurrentRecord().Status == "已收" || this.grid.getCurrentRecord().Status == "已付") {
            alert("此开单已收付，不可作废");
            return false;
        }
        if (this.frmCancelBill == undefined) {
            this.frmCancelBill = new Chenxin.UI.CancelBillFrm({
                scope: this,
                afterGetFormJson: function(json) {
                    delete json.CustomerName;
                    delete json.ContractCode;
                    delete json.HouseAddress;
                    delete json.BillCode;
                    delete json.FundName;
                    delete json.BillMoney;
                    delete json.BillDate;
                }
            });
        }
        if (this.frmCancelBill.show()) {
            var curData = {};
            Chenxin.apply(curData, this.grid.getCurrentRecord());
            curData.BillMoney = curData.TBillMoney;
            this.frmCancelBill.reset();
            this.frmCancelBill.fitData(curData);
        }
    },
    PaymentReg: function() {
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (this.grid.getCurrentRecord().Status == "作废") {
            alert("此开单已作废，不可登记");
            return false;
        } else if (this.grid.getCurrentRecord().Status == "已收" || this.grid.getCurrentRecord().Status == "已付") {
            alert("此开单已收付，不可登记");
            return false;
        }
        if (this.frmPaymentReg == undefined) {
            this.frmPaymentReg = new Chenxin.UI.PaymentRegFrm({
                scope: this,
                afterGetFormJson: function(json) {
                    delete json.CustomerName;
                    delete json.ContractCode;
                    delete json.HouseAddress;
                    delete json.BillType;
                    delete json.BillCode;
                    delete json.FundName;
                    delete json.BillMoney;
                    delete json.BillDate;
                    delete json.ItemPayMoney;
                    delete json.ItemMemo;
                    //json.PayMoney = json.PayMoney.replace("元", "");

                    var lsPayItem = [];
                    var idxCnt = 0;
                    var objPg = this;
                    var payItem = {};
                    $("#tbPayItems tbody tr").each(function() {
                        payItem = {};
                        if ($(this).find("input[name='ItemPayMoney']").length > 0) {
                            if (objPg.frmPaymentReg.lsPayType[idxCnt].getValue() == objPg.frmPaymentReg.lsPayType[idxCnt].defVal) {
                                idxCnt = idxCnt + 1;
                                return true;
                            } else {
                                payItem.PayType = objPg.frmPaymentReg.lsPayType[idxCnt].getValue();
                                payItem.PayMoney = $(this).find("input[name='ItemPayMoney']:eq(0)").val();
                                payItem.Memo = $(this).find("input[name='ItemMemo']:eq(0)").val();
                            }
                            lsPayItem.push(payItem);
                        }
                        idxCnt = idxCnt + 1;
                    });
                    this.frmPaymentReg.additionalParam.PayItems = "[" + lsPayItem.toString() + "]";
                },
                beforeFitData: function(json) {
                    if (json != "{}") {
                        var Now = new Date();
                        json.PayMoney = json.BillMoney;
                        if (json.InOrOut == '1') {
                            json.BillType = "收款单";
                        } else {
                            json.BillType = "付款单";
                        }
                        json.ItemPayMoney = json.PayMoney;
                        json.PayDate = Now.getFullYear() + "-" + (Now.getMonth() + 1).toString().padLeft(2, "0") + "-" + Now.getDate().toString().padLeft(2, "0");
                    }
                }
            });
        }
        if (this.frmPaymentReg.show()) {
            var curData = {};
            Chenxin.apply(curData, this.grid.getCurrentRecord());
            curData.BillMoney = curData.TBillMoney;
            this.frmPaymentReg.reset();
            this.frmPaymentReg.fitData(curData);
        }
    },
    CheckBillInfo: function() {
        var objPg = this;
        var curData = this.grid.getCurrentRecord();
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (curData.Status == "作废") {
            alert("此开单已作废，不可复核");
            return;
        } else if (curData.Status == "未收" || curData.Status == "未付") {
            alert("此开单未收付，不可复核");
            return false;
        }

        if (curData.IsRecheck == true) {
            alert("此开单已复核过了");
            return;
        }
		
		if (confirm('确定要复核吗？')){
			param={};
			Chenxin.applyIf(param,{op:'check',modelid:this.currentId});
			Chenxin.ajax({				
				type: "get",
				dataType: "json",
				url: this.actionUrl,
				data: param,
				onSuccess: function(data,msg) {
					alert(msg);
				}
			});
		}
		
        //this.del('check', '确定要复核吗？');
    },
    UnCheckBillInfo: function() {
        var objPg = this;
        curData = this.grid.getCurrentRecord();
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (curData.Status == "作废") {
            alert("此开单已作废，不可反复核");
            return;
        } else if (curData.Status == "未收" || curData.Status == "未付") {
            alert("此开单未收付，不可反复核");
            return false;
        }
        if (curData.IsRecheck == false) {
            alert("此开单未被复核，不可反复核");
            return;
        }
		
		if (confirm('确定要复核吗？')){
			param={};
			Chenxin.applyIf(param,{op:'uncheck',modelid:this.currentId});
			Chenxin.ajax({				
				type: "get",
				dataType: "json",
				url: this.actionUrl,
				data: param,
				onSuccess: function(data,msg) {
					alert(msg);
				}
			});
		}
        //this.del('uncheck', '确定要反复核吗？');
    },
    CancelPayment: function() {
        var objPg = this;
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (objPg.grid.getCurrentRecord().IsFinish == true) {
            alert("此开单已封帐，不可作废");
            return;
        }
        if (objPg.grid.getCurrentRecord().Status == "作废" || objPg.grid.getCurrentRecord().Status == "未收" || objPg.grid.getCurrentRecord().Status == "未付") {
            alert("请选择已收付开单记录进行操作");
            return;
        }
        if (!confirm("确定要作废此收付款开单吗？")) {
            return;
        }
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async: false,
            url: this.actionUrl,
            data: { op: 'cancelpayment', BillId: this.currentId },
            onSuccess: function(data, msg) {
                alert(msg);
                objPg.reloadGrid();
            }
        });
    },
    RegInvoice: function() {
        var objPg = this;
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (objPg.grid.getCurrentRecord().Status == "作废" || objPg.grid.getCurrentRecord().Status == "未收" || objPg.grid.getCurrentRecord().Status == "未付") {
            alert("请选择已收付开单记录进行操作");
            return;
        }
        if (this.frmRegInvoice == undefined) {
            this.frmRegInvoice = new Chenxin.UI.RegInvoiceForm({
                scope: this,
                afterGetFormJson: function(json) {
                    delete json.CustomerName;
                    delete json.ContractCode;
                    delete json.HouseAddress;
                    delete json.BillType;
                    delete json.BillCode;
                    delete json.FundName;
                    delete json.BillMoney;
                    delete json.BillDate;
                    delete json.ItemPayMoney;
                    delete json.ItemMemo;
                    delete json.PayData;
                    delete json.PayMoney;
                },
                beforeFitData: function(json) {
                    if (json != "{}") {
                        var Now = new Date();
                        if (json.InOrOut = 1) {
                            json.BillType = "收款单";
                        } else {
                            json.BillType = "付款单";
                        }
                        //json.InvoiceDate = Now.getFullYear() + "-" + (Now.getMonth() + 1).toString().padLeft(2, "0") + "-" + Now.getDate().toString().padLeft(2, "0");
                    }
                }
            });
        }
        if (this.frmRegInvoice.show()) {
            var curData = {};
            Chenxin.apply(curData, this.grid.getCurrentRecord());
            curData.BillMoney = curData.TBillMoney;
            this.frmRegInvoice.reset();
            this.frmRegInvoice.fitData(curData);
        }
    },
    RegInvoiceRev: function() {
        var objPg = this;
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (objPg.grid.getCurrentRecord().Status == "作废" || objPg.grid.getCurrentRecord().Status == "未收" || objPg.grid.getCurrentRecord().Status == "未付") {
            alert("请选择已收付开单记录进行操作");
            return;
        }
        if (this.frmRegInvoiceRev == undefined) {
            this.frmRegInvoiceRev = new Chenxin.UI.RegInvoiceRevForm({
                scope: this,
                afterGetFormJson: function(json) {
                    delete json.CustomerName;
                    delete json.ContractCode;
                    delete json.HouseAddress;
                    delete json.BillType;
                    delete json.BillCode;
                    delete json.FundName;
                    delete json.BillMoney;
                    delete json.BillDate;
                    delete json.ItemPayMoney;
                    delete json.ItemMemo;
                    delete json.PayData;
                    delete json.PayMoney;
                },
                beforeFitData: function(json) {
                    if (json != "{}") {
                        var Now = new Date();
                        if (json.InOrOut = 1) {
                            json.BillType = "收款单";
                        } else {
                            json.BillType = "付款单";
                        }
                    }
                }
            });
        }
        if (this.frmRegInvoiceRev.show()) {
            var curData = {};
            Chenxin.apply(curData, this.grid.getCurrentRecord());
            curData.BillMoney = curData.TBillMoney;
            this.frmRegInvoiceRev.reset();
            this.frmRegInvoiceRev.fitData(curData);
        }
    },
    CloseAccount: function() {
        var objPg = this;
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (objPg.grid.getCurrentRecord().Status == "作废" || objPg.grid.getCurrentRecord().Status == "未收" || objPg.grid.getCurrentRecord().Status == "未付") {
            alert("请选择已收付开单记录进行操作");
            return;
        }
        if (objPg.grid.getCurrentRecord().IsFinish) {
            alert("该记录已封帐，不能重复操作！");
            return;
        }
        if (this.frmCloseAccout == undefined) {
            this.frmCloseAccout = new Chenxin.UI.CloseAccoutForm({
                scope: this,
                afterGetFormJson: function(json) {
                    delete json.ContractCode;
                    delete json.BillCode;
                    delete json.FundName;
                    delete json.BillMoney;
                    delete json.BillDate;
                    delete json.PayData;
                    delete json.PayMoney;
                },
                beforeFitData: function(json) {
                    if (json != "{}") {
                        var Now = new Date();
                        json.AchievementDate = Now.getFullYear() + "-" + (Now.getMonth() + 1).toString().padLeft(2, "0");
                    }
                }
            });
        }
        if (this.frmCloseAccout.show()) {
            var curData = {};
            Chenxin.apply(curData, this.grid.getCurrentRecord());
            curData.BillMoney = curData.TBillMoney;
            this.frmCloseAccout.reset();
            this.frmCloseAccout.fitData(curData);
        }
    },
    OpenAccount: function() {
        var objPg = this;
        var curData = objPg.grid.getCurrentRecord();
        if (!this.currentId) {
            alert("请先选择一条开单记录");
            return;
        }
        if (curData.IsFinish == false) {
            alert("此记录未封帐，不可解除封帐");
            return;
        }
        if (!confirm("确定要解除封帐吗？")) {
            return;
        }
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async: false,
            url: this.actionUrl,
            data: { op: 'openaccount', BillId: this.currentId },
            onSuccess: function(data, msg) {
                alert(msg);
                objPg.reloadGrid();
            }
        });
    },
    initComponent: function() {
        Chenxin.UI.ShowListBillPg.superclass.initComponent.call(this);
        //this.searchGrid();
    }
});

/*
**检索条件
*/
Chenxin.UI.ShowListBillSrh = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'divCondition',
    initEvent: function() {
        var _this = this;
        //查询
        $('#btnSearch').click(function() {
            var data = _this.scope.search.getParamJson();
            _this.scope.searchGrid(data);
        });
        $('#txtKeyword').defText({
            deftxt: '输入成交编号/开单号'
        });
        var curdate = new Date();
        $('#starttime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1) + '-1');
        if (curdate.getMonth() + 1 == 12)
            $('#eTime').val(curdate.getFullYear() + 1 + '-1-1');
        else
            $('#eTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 2) + '-1');
    },
    createComboList: function() {
        //合同类型
        var cmbStatus = new Chenxin.UI.Combo({
            containerId: '#Status',
            tbxWidth: 45,
            items: comboCommon.BillStatus
        });
        //款项类型
        var cmbFoundType = new Chenxin.UI.Combo({
            containerId: '#FundName',
            tbxWidth: 45,
            items: comboCommon.FundType
        });
        //开单地点
        var cmbBillPlace = new Chenxin.UI.Combo({
            containerId: '#BillPlaceId',
            name: 'BillPlaceId',
            inModelType: 'txt',
            tbxWidth: 45,
            colWidth: 80,
            items: eval(centerStr)
        });

        //收付款地点
        var cmbPayPlace = new Chenxin.UI.Combo({
            containerId: '#PayPlaceId',
            name: 'PayPlaceId',
            inModelType: 'txt',
            tbxWidth: 45,
            colWidth: 80,
            items: eval(centerStr)
        });

        //单据
        var cmbInOrOut = new Chenxin.UI.Combo({
            containerId: '#inorout',
            tbxWidth: 45,
            colWidth: 80,
            items: [{val:'1',txt:'收款单'}, {val:'-1',txt:'付款单'}]
        });
		
		//日期类型
        var cmbDateType = new Chenxin.UI.Combo({
            containerId: '#datetype',
			addPleaseSelected:false,
            tbxWidth: 55,
            colWidth: 80,
            items: [{val:'10',txt:'开单日期'}, {val:'20',txt:'收付日期'}, {val:'30',txt:'实收归属'},{val:'30',txt:'业绩归属'}]
        });
		
		

        //复核
        var cmbIsFinish = new Chenxin.UI.Combo({
            containerId: '#IsFinish',
            tbxWidth: 45,
            colWidth: 80,            
            items: [{ val: 'true', txt: '封帐' }, { val: 'false', txt: '未封帐'}]
        });

        //封帐
        var cmbIsRecheck = new Chenxin.UI.Combo({
            containerId: '#IsRecheck',
            tbxWidth: 45,
            colWidth: 80,
            items: [{ val: 'true', txt: '复核' }, { val: 'false', txt: '未复核'}]
        });

        var combl = new Chenxin.UI.StructComboList();
        var structs = combl.comboList;
        structs.push(cmbStatus);
        structs.push(cmbFoundType);
        structs.push(cmbBillPlace);
        structs.push(cmbPayPlace);
        structs.push(cmbInOrOut);
        structs.push(cmbIsFinish);
        structs.push(cmbIsRecheck);
		structs.push(cmbDateType);
		
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.ShowListBillSrh.superclass.initComponent.call(this);
    }
});

/*
*开单作废窗口
*/
Chenxin.UI.CancelBillFrm = Chenxin.extend(Chenxin.UI.FormCommon, {
    id: 'jqmCancelBill',
    renderTo: 'jqmCancelBill',
    actionUrl: '/service/logic/ShowListBill.ashx',
    title: '开单作废',
    op: 'cancelbill',
    defBBtn: true,
    createForm: function() {
        return formCommon.CancelBillForm();
    },
    saveSucc:function(){
        //this.reloadGrid();
    },
    initFormValidator: function() {
        //作废原因
        $("#txtaUnusedReason").formValidator({
            validatorgroup: this.id,
            onshow: "请输入作废原因！",
            onfocus: "作废原因为必输项目",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "作废原因不能为空！"
            },
            onerror: "作废原因不能为空！"
        });
        //作废时间
        $("#txtUnusedDate").formValidator({
            validatorgroup: this.id,
            onshow: "请输入作废时间！",
            onfocus: "作废时间格式：YYYY-MM-DD",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "作废时间不能为空！"
            },
            onerror: "作废时间不能为空！"
        });
    },
    initEvent: function() {
        /*******事件：作废时间******/
        $("#txtUnusedDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
    }
});

/*
*收付款登记窗口
*/
Chenxin.UI.PaymentRegFrm = Chenxin.extend(Chenxin.UI.FormCommon, {
    id: "jqmPaymentReg",
    rendeTo: "jqmPaymentReg",
    actionUrl: "/service/logic/ShowListBill.ashx",
    op: "regpayment",
    title: "收付款登记",
    defBBtn: false,
    maxItemCnt: 0,
    lsPayType: [],
    createBBtn: function() {
        return [{ text: '确定', handler: this.frmSubmit, scope: this },
                { text: '取消', handler: this.hide, scope: this}];
    },
    frmSubmit: function() {
        var objFrm = this;
        if ($("#txtPayDate").val() == "") {
            alert("请输入收付款日期！");
            $("#txtPayDate").focus();
            return;
        }
        if ($("#chkIsFinish").attr("checked") == true) {
            if ($("#txtInvoiceCode").val() == "" || $("#txtInvoiceDate").val() == "") {
                alert("财务封帐时必须完整填写发票信息！");
                return;
            }
        }
        if (($("#txtInvoiceCode").val() != "" && $("#txtInvoiceDate").val() == "") || ($("#txtInvoiceCode").val() == "" && $("#txtInvoiceDate").val() != "")) {
            alert("请完整输入发票信息或不输入！");
            return;
        }
        var idxCnt = 0;
        var valItemMoney;
        var valType;
        var TotalMoney = 0;
        var bNeedChkTotal = true;
        $("#tbPayItems tbody tr").each(function() {
            valItemMoney = $(this).find("input[name='ItemPayMoney']:eq(0)").val();
            if (valItemMoney == undefined) {
                return true;
            }
            valType = objFrm.lsPayType[idxCnt].getValue();
            if (valItemMoney == "" && valType == "请选择") {
                return true;
            }
            if (valItemMoney != "" && valType == "请选择") {
                alert("请选择支付方式！");
                bNeedChkTotal = false;
                return false;
            } else if (valItemMoney == "" && valType != "请选择") {
                alert("请输入收付款金额！");
                bNeedChkTotal = false;
                return false;
            } else if (!valItemMoney.isNum()) {
                alert("输入的收付款金额为非金额格式！");
                bNeedChkTotal = false;
                return false;
            } else {
                TotalMoney = TotalMoney + parseFloat(valItemMoney);
            }
            idxCnt = idxCnt + 1;
        });
        if (bNeedChkTotal) {
            var PayMoney = parseFloat($("#txtPayMoney").val());
            if (PayMoney != TotalMoney) {
                alert("款项相加总金额需等于开单金额！");
                return;
            }
        } else {
            return;
        }
        if (this.comboList[0].getValue() == this.comboList[0].defVal) {
            alert("请选择收付款签约点！");
            return;
        }
        this.save();
    },
    saveSucc: function() {
        //this.reloadGrid();
    },
    createForm: function() {
        var strRet = "";
        strRet = strRet + '<table class="tbl_f">';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th style="width:100px">客户姓名：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "CustomerName" /><input type="hidden" name="BillId"></td>';
        strRet = strRet + '<th style="width:100px">成交编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "ContractCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>房屋地址：</th>';
        strRet = strRet + '<td colspan="3"><input type="text" class="inputbox_n fl" style="width:422px" readonly name = "HouseAddress" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单类型：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillType" /></td>';
        strRet = strRet + '<th>开单编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>款项名称：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "FundName" /></td>';
        strRet = strRet + '<th>合同所属：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "ContractCompany" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillMoney" /></td>';
        strRet = strRet + '<th>开单日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;border-bottom: 2px solid  silver;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>收付款金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayMoney" id="txtPayMoney" /></td>';
        strRet = strRet + '<th>收付款日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayDate" id="txtPayDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>发票单号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" name = "InvoiceCode" id="txtInvoiceCode"/></td>';
        strRet = strRet + '<th>发票日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "InvoiceDate" id="txtInvoiceDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:10px;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="4"><span style="font-weight:bold;color:blue">请选择每笔款项的支付方式</span><td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="4">';
        strRet = strRet + '<table class="tabsorternew" id="tbPayItems">';
        strRet = strRet + '<thead>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th style="text-align:center">支付方式</th>';
        strRet = strRet + '<th style="text-align:center">收付款金额</th>';
        strRet = strRet + '<th style="text-align:center">备注</th>';
        strRet = strRet + '<th style="text-align:center">操作</th>';
        strRet = strRet + '</tr>';
        strRet = strRet + '</thead>';
        strRet = strRet + '<tbody>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="4"><div class="btn btn5 fr"><a title="添加支付明细" href="javascript:void(0)" id="aAddPayItem"><span>添加支付明细</span></div></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '</tbody>';
        strRet = strRet + '</table>';
        strRet = strRet + "</td>"
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="2"><input type="checkbox" name="IsFinish" id="chkIsFinish" value="true"><span style="color:red">登记发票同时生产财务封帐</span></td>';
        strRet = strRet + '<th>收付款签约点：</th>';
        strRet = strRet + '<td><div id="RegPayPlaceId" style="z-index:1" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '</table>';
        return strRet;
    },
    addPayItem: function() {
        var strRet = "";
        var objAddBefore = $("#tbPayItems").children("tbody").children("tr:last");
        strRet = strRet + '<tr>';
        strRet = strRet + '<td style="width:120px"><div id="PayType' + this.maxItemCnt.toString().padLeft(2, "0") + '" class="SelectWrapSingle" style="z-index:' + (100 - this.maxItemCnt).toString() + '"  /></td>';
        strRet = strRet + '<td style="width:100px"><input type="text" class="inputbox_n fl" name = "ItemPayMoney" style="width:80px" /></td>';
        strRet = strRet + '<td style="width:320px"><input type="text" class="inputbox_n fl" name = "ItemMemo" style="width:300px" /></td>';
        strRet = strRet + '<td><a name="aDelPayItem" title="删除支付明细" href="javascript:void(0)" >删除</a></td>';
        strRet = strRet + '</tr>';

        objAddBefore.before(strRet);
        //支付方式
        var cmbFoundType = new Chenxin.UI.Combo({
            containerId: "#PayType" + this.maxItemCnt.toString().padLeft(2, "0"),
            tbxWidth: 80,
			initVal:'现金',
            items: comboCommon.PayType
        });
		cmbFoundType.setValue('现金');
        this.lsPayType.push(cmbFoundType);
        this.maxItemCnt = this.maxItemCnt + 1;
    },
    createComboList: function() {
        var cmbPayPlace = new Chenxin.UI.Combo({
            containerId: '#RegPayPlaceId',
			name:'PayPlace',
			inModelType:'txt',
            tbxWidth: 96,
			colWidth:80,
            items: eval(centerStr),//comboCommon.ContractCenter,
			required: true
        });
		//签约中心/门店
		/*
        var cmbPayPlace = new Chenxin.UI.StructCombo({
            param: { op: 'getsignplaces' },
            containerId: '#RegPayPlaceId',
            name: 'PayPlaceId',
            inModelType: 'all',
            txtModelName: 'PayPlace',
            required: false,
            tbxWidth: 96,
            colWidth: 80
        });*/
        return [cmbPayPlace];
    },
    initEvent: function() {
        var objFrm = this;
        /***********事件：收付款日期*********/
        $("#txtPayDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
        /************事件：发票日期***********/
        $("#txtInvoiceDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
        /********事件：添加一条支付明细**********/
        $("#aAddPayItem").click(function() {
            objFrm.addPayItem();
        });
        /********事件：删除一条支付明细**********/
        $("A[name='aDelPayItem']").live("click", function() {
            var idxCurTr = $(this).parents("tbody:first").children("tr").index($(this).parents("tr:first"));
            $(this).parents("tr:first").remove();
            objFrm.lsPayType.splice(idxCurTr, 1);
        });
        //        //添加一条支付明细
        //        this.addPayItem();
    },
    reset: function() {
        var objTrs = $("#tbPayItems").children("tbody").children("tr");
        this.fitData({});
        this.lsPayType.length = 0;
        this.maxItemCnt = 0;
        objTrs.each(function() {
            if ($(this).find("input[name='ItemPayMoney']").length > 0) {
                $(this).remove();
            }
        });
        this.addPayItem();
    }
});

/*
**发票号登记窗体
*/
Chenxin.UI.RegInvoiceForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    id: "jqmRegInvoice",
    rendeTo: "jqmRegInvoice",
    actionUrl: "/service/logic/ShowListBill.ashx",
    op: "reginvoice",
    title: "登记发票号",
    defBBtn: true,
    saveSucc: function() {
        //this.reloadGrid();
    },
    createForm: function() {
        var strRet = "";
        strRet = strRet + '<table class="tbl_f">';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th style="width:100px">客户姓名：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "CustomerName" /><input type="hidden" name="BillId"></td>';
        strRet = strRet + '<th style="width:100px">成交编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "ContractCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>房屋编号：</th>';
        strRet = strRet + '<td colspan="3"><input type="text" class="inputbox_n fl" style="width:419px" readonly name = "HouseAddress" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单类型：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillType" /></td>';
        strRet = strRet + '<th>开单编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>款项名称：</th>';
        strRet = strRet + '<td colspan="3"><input type="text" class="inputbox_n fl" readonly name = "FundName" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillMoney" /></td>';
        strRet = strRet + '<th>开单日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>收付款金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayMoney"/></td>';
        strRet = strRet + '<th>收付款日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayDate"/></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;border-bottom: 2px solid  silver;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="4"><span style="font-weight:bold;color:blue">请填写发票号和发票日期</span><td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>发票单号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" name = "InvoiceCode" id="txtRegInvoiceCode"/></td>';
        strRet = strRet + '<th>发票日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "InvoiceDate" id="txtRegInvoiceDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th></th>';
        strRet = strRet + '<td><div id="txtRegInvoiceCodeTip" style="float: left; margin-left: 5px; width: 180px; height: 26px; line-height: 26px; text-align: left;" ></td>';
        strRet = strRet + '<th></th>';
        strRet = strRet + '<td><div id="txtRegInvoiceDateTip" style="float: left; margin-left: 5px; width: 180px; height: 26px; line-height: 26px; text-align: left;" ></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="4"><input type="checkbox" name="IsFinish" value="true"><span style="color:red">登记发票同时生产财务封帐</span></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '</table>';
        return strRet;
    },
    initFormValidator: function() {
        //发票单号
        $("#txtRegInvoiceCode").formValidator({
            validatorgroup: this.id,
            onshow: "请输入发票单号！",
            onfocus: "发票单号为必输项目",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "发票单号不能为空！"
            },
            onerror: "发票单号不能为空！"
        });
        //发票时间
        $("#txtRegInvoiceDate").formValidator({
            validatorgroup: this.id,
            onshow: "请输入发票时间！",
            onfocus: "发票时间格式：YYYY-MM-DD",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "发票时间不能为空！"
            },
            onerror: "发票时间不能为空！"
        });
    },
    initEvent: function() {
        /***************事件：发票日期事件***********/
        $("#txtRegInvoiceDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
    }
});

/*
**发票领取记录登记
*/
Chenxin.UI.RegInvoiceRevForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    id: "jqmRegInvoiceRev",
    rendeTo: "jqmRegInvoiceRev",
    actionUrl: "/service/logic/ShowListBill.ashx",
    op: "reginvoicerev",
    title: "发票领取记录",
    defBBtn: true,
    saveSucc: function() {
        //this.reloadGrid();
    },
    createForm: function() {
        var strRet = "";
        strRet = strRet + '<table class="tbl_f">';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th style="width:100px">客户姓名：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "CustomerName" /><input type="hidden" name="BillId"></td>';
        strRet = strRet + '<th style="width:100px">成交编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "ContractCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>房屋编号：</th>';
        strRet = strRet + '<td colspan="3"><input type="text" class="inputbox_n fl" style="width:418px" readonly name = "HouseAddress" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单类型：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillType" /></td>';
        strRet = strRet + '<th>开单编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>款项名称：</th>';
        strRet = strRet + '<td colspan="3"><input type="text" class="inputbox_n fl" readonly name = "FundName" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillMoney" /></td>';
        strRet = strRet + '<th>开单日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>收付款金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayMoney"/></td>';
        strRet = strRet + '<th>收付款日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayDate"/></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;border-bottom: 2px solid  silver;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<td colspan="4"><span style="font-weight:bold;color:blue">请填写发票领取记录</span><td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>发票领取记录：</th>';
        strRet = strRet + '<td colspan=3><textarea name="InvoiceMemo" cols="80" rows="5" style="width:420px" class="textarea_n" id="txtaInvoiceMemo" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th></th>';
        strRet = strRet + '<td colspan=3><div id="txtaInvoiceMemoTip" style="float: left; margin-left: 5px; width: 180px; height: 26px; line-height: 26px; text-align: left;" ></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '</table>';
        return strRet;
    },
    initFormValidator: function() {
        //发票领取记录
        $("#txtaInvoiceMemo").formValidator({
            validatorgroup: this.id,
            onshow: "请输入发票领取记录！",
            onfocus: "发票领取记录为必输项目",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "发票领取记录不能为空！"
            },
            onerror: "发票领取记录不能为空！"
        });
    }
});

/*
**
*/
Chenxin.UI.CloseAccoutForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    id: "jqmCloseAccout",
    rendeTo: "jqmCloseAccout",
    actionUrl: "/service/logic/ShowListBill.ashx",
    op: "closeaccout",
    title: "财务封帐",
    defBBtn: true,
	afterCheckPermit:function(data){
		if(data.selectAllDate){
			var date=new Date();
			this.minDate=(date.getFullYear()-100)+'-'+(date.getMonth()+1)+'-01';
		}
	},
    saveSucc: function() {
        //this.reloadGrid();
    },
    createForm: function() {
        var strRet = "";
        strRet = strRet + '<table class="tbl_f">';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th style="width:100px">开单编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillCode" /><input type="hidden" name="BillId" /></td>';
        strRet = strRet + '<th style="width:100px">成交编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "ContractCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>款项名称：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "FundName" /></td>';
        strRet = strRet + '<th>发票编号：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "InvoiceCode" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>开单金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillMoney" /></td>';
        strRet = strRet + '<th>开单日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "BillDate" /></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>收付款金额：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayMoney"/></td>';
        strRet = strRet + '<th>收付款日期：</th>';
        strRet = strRet + '<td><input type="text" class="inputbox_n fl" readonly name = "PayDate"/></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;border-bottom: 2px solid  silver;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr style="height:5px;">';
        strRet = strRet + '<td colspan="4"></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '<tr>';
        strRet = strRet + '<th>实收归属：</th>';
        strRet = strRet + '<td colspan=3><input type="text" class="inputbox_n fl x-input-date" readonly name = "AchievementDate" id="txtAchievementDate" />';
        strRet = strRet + '<div id="txtAchievementDateTip" style="float: left; margin-left: 5px; width: 200px; height: 26px; line-height: 26px; text-align: left;" ></td>';
        strRet = strRet + '</tr>';
        strRet = strRet + '</table>';
        return strRet;
    },
    initFormValidator: function() {
        //实收归属
        $("#txtAchievementDate").formValidator({
            validatorgroup: this.id,
            onshow: "请输入实收归属！",
            onfocus: "实收归属格式为：YYYY-MM",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "实收归属不能为空！"
            },
            onerror: "实收归属不能为空！"
        });
    },
    initEvent: function() {
        /*******事件：作废时间******/
        // $("#txtAchievementDate").focus(function() {
            // WdatePicker({
                // dateFmt: 'yyyy-MM',
                // oncleared: function() {
                    // $(this).blur();
                // },
                // onpicked: function() {
                    // $(this).blur();
                // }
            // });
        // });
		
		var _this=this;
		$('.x-input-date').focus(function() {
			WdatePicker({ 
                dateFmt: 'yyyy-MM',
				oncleared: function() { 
					$(this).blur(); 
				}, 
				onpicked: function() { 
					$(this).blur(); 
				},
				readOnly:true,
				minDate:_this.minDate
			});
		});
    },
	initComponent:function(){
		
		var date=new Date();
		this.minDate=date.getFullYear()+'-'+(date.getMonth()+1)+'-01';
		Chenxin.UI.CloseAccoutForm.superclass.initComponent.call(this);
	}
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var objPg  = new Chenxin.UI.ShowListBillPg();
});